package com.hnucm.cooklife.base;

import androidx.annotation.Nullable;

import com.google.gson.Gson;

import java.io.IOException;

import okhttp3.MediaType;
import okhttp3.RequestBody;
import retrofit2.Converter;

public class DishDetailRequestBodyConverter<T> implements Converter<T, RequestBody> {

    private Gson mGson = new Gson();

    @Nullable
    @Override
    public RequestBody convert(T value) throws IOException {
        String json = mGson.toJson(value);
        return RequestBody.create(MediaType.parse("application/json; charset=UTF-8"),
                json);
    }
}
